package day09.task;

import java.util.ArrayList;

public abstract class Pet {
    private int intimacies;//亲密度
    private int health_value;//健康度
    private int ID;

//    @Override
//    public String toString() {
//        return "Pet{" +
//                "intimacies=" + intimacies +
//                ", health_value=" + health_value +
//                ", ID=" + ID +
//                '}';
//    }

    public Pet() {
    }

    public Pet(int ID) {
        this.intimacies = 100;
        this.health_value = 100;
        this.ID = ID;
    }

    public int getIntimacies() {
        return intimacies;
    }

    public int getID() {
        return ID;
    }

    public void setID(int ID) {
        this.ID = ID;
    }

    public void setIntimacies(int intimacies) {
        this.intimacies = intimacies;
    }

    public int getHealth_value() {
        return health_value;
    }

    public void setHealth_value(int health_value) {
        this.health_value = health_value;
    }

    public abstract void play();
}

class Dog extends Pet {
    public Dog() {
    }

    public Dog(int id) {
        super(id);
    }

    public void play() {
        setHealth_value(getHealth_value() - 10);
        setIntimacies(getIntimacies() + 5);
        System.out.println("主人和编号为" + getID() + "的狗狗玩飞盘游戏,健康值：" + getHealth_value() + "亲密度" + getIntimacies());


    }
}

class Penguin extends Pet {
    public Penguin() {
    }

    public Penguin(int ID) {
        super(ID);
    }

    public void play() {
        setHealth_value(getHealth_value() - 5);
        setIntimacies(getIntimacies() + 5);
        System.out.println("主人和编号为" + getID() + "的企鹅玩游泳游戏,健康值：" + getHealth_value() + "亲密度" + getIntimacies());
    }
}

class Master {
    private Pet pet;

public Pet getPet(){
    return pet;
}
    public void setPet(Pet pet) {
        this.pet = pet;
    }

    public void getPet(int ID) {
        if (ID == 1) {
            pet = new Dog(ID);
        } else if (ID == 2) {
            pet = new Penguin(ID);
        }
    }

    public void playWithPet() {
        if (pet != null) {
            pet.play();
        } else
            System.out.println("主人没有宠物");
    }
}

class Main4 {
    public static void main(String[] args) {
        Master m = new Master();
        m.getPet(1);//领养狗
        m.playWithPet();
        System.out.println(m.getPet());
        m.getPet(2);
        m.playWithPet();
        System.out.println(m.getPet());
    }
}